package com.hd.trans.network.bean

import java.util.Objects

/**
 * 翻译的段落
 */
class TransSubsection(var taskId:String) {

    var isFromLang = true // 用于确定显示在列表的左侧还是右侧（没有需求则忽略）

    var originalContent = "" //已确定的识别内容
        private set

    var translateContent = "" //originalContent的翻译内容
        private set

    var msg:String? = null //尚未确定下来的识别内容
    var msg2:String? = null //msg的翻译内容


    fun hasOriginalContent(): Boolean {
        return originalContent.trim().isNotEmpty()
    }

    fun hasTranslateContent(): Boolean {
        return translateContent.trim().isNotEmpty()
    }

    fun appendOrgContent(content:String,recordTimeMillis:Long): TransSubsection {
        originalContent += content
        return this
    }

    fun appendTraContent(content:String): TransSubsection {
        translateContent += content
        return this
    }

    fun isEmpty(): Boolean {
        if (!msg.isNullOrEmpty())
            return false
        return !hasOriginalContent() || !hasTranslateContent()
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as TransSubsection

        return taskId == other.taskId
    }

    override fun hashCode(): Int {
        return Objects.hash(taskId)
    }

}